Architecture: Objects

The objects provided by the SDK are arranged in a containment hierarchy. Beginning with the Application object, you can get other objects "contained" by the Application, such as the Drawing objects that the application manages. Below are listed some of the basic objects and their responsibilities. For a complete reference to the hierarchy, consult the object model API reference page.

The Application Object

The Application object represents the currently running TurboCAD v4 session. The Application exists primarily to manage one or more Drawing objects, as well as make available services and objects to the Drawings. Some of the other objects accessible from the Application object are:

NamedColor

Entries in a look-up table for specifying colors in a palette by name, rather than RGB or HSV value

RegenMethod

Extensions to TurboCAD's primitive graphic types

Filter

Allow for opening and saving of drawing data in a variety of file formats

Tool

Allow for the creation of new user interface procedures

User interface

Allow for the runtime customization of TurboCAD's user interface (Menus, Toolbars, etc.)

Application Property

Allow you to change the values of session-wide attributes

AppOptions

Controls some of the session-wide behavior of TurboCAD v4

System

Provides the programmer with information about the current state of the operating system

The Drawing Object

The Drawing object represents the document in TurboCAD v4, that is, a unit that can be saved to persistent storage. Drawings contain Graphics collections that allow you to manipulation all the graphical entities (Graphic objects) in the drawing.

The graphics in the drawing can be grouped in other pseudo-collections:

Selection

Pseudo-collection of references to all the graphical entities in the drawing with a selection attribute

Arbitrary Graphic Set

Pseudo-collection of references to Graphic objects in the drawing

Other aspects of Drawings are manipulated through specific objects in the model:

Layer

Control the grouping and visibility of Graphics

LineStyle

Control the different line types available in a drawing

BrushStyle

Control the different fill types available in a drawing

Drawing Property

Provide access to drawing-wide attributes

DwgOptions

Sets some of the drawing-specific behavior

Graphic Objects

Graphic objects can be created independent of a drawing, and added to a drawing's Graphics collection at a later time.

Graphic objects are organized in a hierarchy.

Other attributes of the graphic are Editable...

A Graphic object's geometry is described by the Vertex objects in its Vertices collection.

Vertex Objects

Vertex objects can exist outside of a Graphic object's Vertices collection.

Vertex attributes:

Don't add or delete vertices in Arc, Text, OLEObject or RegenMethod graphics. Manipulating vertices in a Graphic object can cause the RegenMethod to change the appearance of the graphic.

Accessing Named Object Properties: The Property Object

In addition to calling methods on the objects in the TurboCAD SDK, a common way to program is to get and set named, customizable, object properties. For the Application, Drawing and Graphic objects, these are exposed by a Property object, contained in a Properties collection that can be accessed by the parent object. For example in order to change the pen color of a Graphic object, neither a PenColor property nor a SetPenColor method is provided. Instead a object that represents the PenColor property is obtained by indexing the name "PenColor" in the Graphic's Properties collection, and then setting its value. This allows for the addition of a large number of properties to these objects without cluttering the interface of the parent object.

Properties specified by Property objects can be built in, provided by the the TurboCAD system, or custom, added by the user at runtime. The Property objects contained by the parent objects are classified as follows:

In addition, a slightly different interface is provided for Microsoft Office standard Document properties, such as Author, Keywords, etc. that can be browsed by Microsoft Office-compatible applications.

A deeper discussion on Property objects can be found here.

The Viewport Object

There are two kinds of Viewport objects, built-in and custom. 

Custom viewports can be destroyed via the Viewport.Delete method.

Drawing in a Viewport

Viewports allow four different methods of drawing:

Only one type of special drawing (bitmap or metafile) can be done between calls to OpenBitmap and CloseBitmap, or OpenMetafile and CloseMetafile. Make sure that every OpenBitmap/Metafile call has a corresponding CloseBitmap/Metafile call.

The Selection Object

The Selection collection represents a special collection of graphic objects in a drawing that are in the selected state. Graphics can be added to the Selection collection by any number of methods:

Whether the selection is added to or replaced by a selection operation is determined by the state of the Application.ReplaceSelection boolean property. When running the EXE (local) server, changing the contents of the selection automatically forces the Selection Tool to become active. Operations on Selection objects are the same as those permitted on a Graphics collection or a GraphicSet collection.

Picking

Picking is accomplished by the Viewport.Pick methods. Pick methods return a PickResult collection. To select all the graphics in a PickResult, use the PickResult.Select method. Each PickEntry in a PickResult contains a reference to a Graphic.

These Graphic objects can be analyzed independently and used (selected or put into a GraphicSet, for example) as necessary.

Low-level and High-level Graphic Methods

High-level methods closely mimic the TurboCAD user interface. High-level methods provide geometrical solutions: Line tangent to circle, etc. High-level methods create undoable actions without explicit programming. High-level methods are denoted in SDK by [...todo...] Low-level methods don't create undo records. Low-level methods allow fine-grained access to vertices, cosmetic attributes, etc. The programmer can create undo records through the UndoRecord object interface.

Undo Record Objects

TurboCAD has an undo system that is invoked by the user interface, as well as by high-level SDK methods (see high-level vs. low-level discussion). If you are using low-level SDK methods, you can create undoable actions by directly programming the methods of the UndoRecord object. UndoRecords are created and placed on a stack in the Drawing. The Drawing maintains a pointer into the stack.

Actions are undone by moving down the stack, or redone by moving up the stack. There are three typical scenarios to make an operation that modifies the graphics in a drawing undoable.

Customizing TurboCAD

Several types of "extension" objects exist to allow programmers to extend the core functionality of TurboCAD. Samples of how to create these objects and add them to the TurboCAD system are presented in the documentation. Regen method objects allow the creation and management of special graphic types that respond to changes in properties and geometry in a structured, algorithmic way ('smart' graphic behavior). Filter objects allow the importing and exporting of drawing data from and to new file types. Tool objects allow the creation of new toolbar buttons and menu items in the TurboCAD user interface, and permit the programmatically controlled modification of the layout of TurboCAD's menus and toolbars at runtime.

Previous Next

SDK Top API Reference TurboCAD Home Page TurboCAD Programming Forums